package com.shine.spring.boot.action.jpa.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

/**
 * @author: Forward Seen
 * @version:
 * @description: 打印使用的数据库连接池
 * @createTime: 2023/9/10 17:57
 * @since: 1.8
 */
@Component
public class DataSourceShow implements ApplicationContextAware {

    ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
        DataSource dataSource = applicationContext.getBean(DataSource.class);
        System.out.println("data source:" + dataSource.getClass().getName());
    }
}
